package com.yc.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yc.bean.RepliesBean;
import com.yc.bean.ReviewBean;
import com.yc.mapper.FoodRepliesMapper;
import com.yc.mapper.ReviewMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zwei
 * @create 2024-10-07 18:35
 */
@Service
public class ReviewBizImpl implements ReviewBiz{
    private final ReviewMapper reviewMapper;
    private final FoodRepliesMapper foodRepliesMapper;
    @Autowired
    public ReviewBizImpl(ReviewMapper reviewMapper, FoodRepliesMapper foodRepliesMapper) {
        this.reviewMapper = reviewMapper;
        this.foodRepliesMapper = foodRepliesMapper;
    }
    @Override
    public List<ReviewBean> getreview(Integer id) {
        QueryWrapper<ReviewBean> qw=new QueryWrapper<>();
        qw.eq("foodid",id).orderByDesc("id");
        List<ReviewBean> list = reviewMapper.selectList(qw);
        return list;
    }

    @Override
    public List<RepliesBean> getReplies() {
        LambdaQueryWrapper<RepliesBean>qw=new LambdaQueryWrapper<>();
        qw.orderByDesc(RepliesBean::getCreatedate);
        List<RepliesBean>list=foodRepliesMapper.selectList(null);
        return list;
    }
}
